{__NOLAYOUT__}
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
	{include file="public/script" /}
</head>
<body>
	<div class="sectionH sectionH2 mui-clearfix">
		<header class="mui-bar mui-bar-nav" style="">
			<a class="mui-icon mui-icon-left-nav  mui-pull-left" href="javascript:history.back(-1)" style="color: #727272;"></a>
			<h1 class="mui-title">全部商会</h1>
			<!--<a class="mui-icon mui-pull-right right1" href="javascript:;" style="padding-top: 10px;"><img src="__STATIC__/www/images/nav_icon_search.png"/></a>-->
		</header>
	</div>
	<div class="kong1"></div>
	<div class="all_shanghui_section1" id="items" style="position: absolute;z-index: 2;width: 100%;height: 93%;">
			<div class="container" style="position: absolute;width: 100%;z-index: 1;">
				<!--<div class="sbn">-->
					<!--<input type="text" placeholder="请输入内容"/>-->
					<!--<input type="submit" style="display: none;" class="submit"/>-->
					<!--<img src="__STATIC__/www/images/nav_icon_search.png" alt="" class="sub_yy"/>-->
				<!--</div>-->

					<div class="items" style="position: relative;">
						{volist name="list" id="l"}
						<div class="items-1">

								<div class="items-1-1 mui-clearfix">
									<a href="{:url('Bussiness/index',array('id'=>$l.id))}"><p class="p1"><img src="{$l.avatar}"/><span>{$l.title}</span></p></a>
									{if condition="$l['is_follow']==1"}
									<p class="p2"><span class=" select">已关注</span></p>
									{else/}
									<p class="p2"><a href="javascript:follow_bussiness({$l.id})"><span class="" >关注</span></a></p>
									{/if}

								</div>
								<div class="items-1-2">
									<p class="p1">会长：<span>{$l.head}</span></p>
									<p class="p1">会员：{$l.member_num}人</p>
									<p class="p1">电话：{$l.tel}</p>
									<p class="p1">地址：{$l.address}</p>
								</div>


						</div>
						{/volist}

					</div>


			</div>
		</div>

</body>

<script>
    mui.init({
        pullRefresh: {
            container: '#items',
            down: {

            },
            up: {
                auto:false,
                contentrefresh: '正在加载...',
                callback: pullupRefresh
            }
        }
    });
    var count = 1;
    function pullupRefresh() {
        setTimeout(function() {
            // mui('#items').pullRefresh().endPullupToRefresh((++count > 2)); //参数为true代表没有更多数据了。
            var table = document.body.querySelector('.items');
            var url="{:url('Bussiness/bussinessList')}";
            count++;
            $.post(url,{page:count,page_size:5},function(data){
                var data=JSON.parse(data);
                if(data==0)
                {
                    mui('#items').pullRefresh().endPullupToRefresh((data==0));
                }else{
                    for (var i = 0; i < data.length; i++) {
                        var li = document.createElement('div');
                        var url1="/Bussiness/index/id/"+data[i]['id'];
                        var is_follow=data[i]["is_follow"];
                        li.className = 'items-1';
                        if(is_follow==1)
                        {
                            li.innerHTML = '<div class="items-1-1 mui-clearfix">\n' +
                                '\t\t<a href="\'+url1+\'"><p class="p1"><img src="'+data[i]["avatar"]+'"/><span>'+data[i]['title']+'</span></p></a>\n' +
                                '\t\t<p class="p2"><span class="Focus select">已关注</span></p>\n' +
                                '\t</div>\n' +
                                '\t<div class="items-1-2">\n' +
                                '\t\t<p class="p1">会长：<span>'+data[i]["title"]+'</span></p>\n' +
                                '\t\t<p class="p1">会员：'+data[i]["member_num"]+'人</p>\n' +
                                '\t\t<p class="p1">电话：'+data[i]["tel"]+'</p>\n' +
                                '\t\t<p class="p1">地址：'+data[i]["address"]+'</p>\n' +
                                '\t</div>';
						}else{
                            li.innerHTML = '<div class="items-1-1 mui-clearfix">\n' +
                                '\t\t<a href="\'+url1+\'"><p class="p1"><img src="'+data[i]["avatar"]+'"/><span>'+data[i]['title']+'</span></p></a>\n' +
                                '\t\t<p class="p2"><a href="javascript:follow_bussiness('+data[i]["id"]+')"><span class="">关注</span></a></p>\n' +
                                '\t</div>\n' +
                                '\t<div class="items-1-2">\n' +
                                '\t\t<p class="p1">会长：<span>'+data[i]["title"]+'</span></p>\n' +
                                '\t\t<p class="p1">会员：'+data[i]["member_num"]+'人</p>\n' +
                                '\t\t<p class="p1">电话：'+data[i]["tel"]+'</p>\n' +
                                '\t\t<p class="p1">地址：'+data[i]["address"]+'</p>\n' +
                                '\t</div>';
						}

                        table.appendChild(li);

                    }

                }
                mui('#items').pullRefresh().endPullupToRefresh((data==0));
            })

        }, 1000);
    }

</script>
<script>
    /*关注商会*/
    function follow_bussiness(bussiness_id) {

        var ids= new Array();

        if(bussiness_id<=0)
        {
            mui.alert("没有可关注的商会！");
            return fasle;
        }
        ids.push(bussiness_id);
        ids=JSON.stringify(ids);

        var url="{:url('Connection/Follow')}";
        $.post(url,{ids:ids,type:2},function(data){
            var data=JSON.parse(data);
            if(data.result_code==='0000')
            {
                mui.alert("关注成功！","提示",function(){
                    window.location.reload();
                });

            }else{
                mui.alert(data.result_info,"提示",function(){
                    window.location.reload();
                });
            }
        })
    }
</script>

</html>